package com.yiwei.zhh.api.requestInfo;

import com.yiwei.zhh.api.Api;
import com.yiwei.zhh.api.bean.UploadImageBean;
import com.yiwei.zhh.api.callback.FaceContract;
import com.yiwei.zhh.util.Network;
import com.yiwei.zhh.util.RxLifeUtil;
import com.yiwei.zhh.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class FaceRequest extends BaseRequest<FaceContract.View> implements FaceContract.Presenter<FaceContract.View> {

    public static FaceRequest create() {
        return new FaceRequest();
    }


    @Override
    public void updateFace(String base64) {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail).show();
            return;
        }
        mView.onRequestStart();
        UploadImageBean bean = new UploadImageBean();
        bean.img = base64;
        Api.api_service.uploadImageFace(bean).compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();
                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.updateFaceSuccess(result);
                });
    }
}
